#include "pac.h"

// Картата, в която се казва дали поле е заето или свободно
extern char map[COLS][ROWS];
extern void dotEaten(int x, int y);

Pacman::Pacman(Spritesheet * sheet, int _x, int _y):
Actor(_x, _y, sheet, PACMAN)
{
    dots_eaten = 0;
    times_died = 0;
    ghosts_eaten = 0;
    score = 0;
    moves_per_second = 100;
}

void Pacman::eat_ghost()
{
    ++ghosts_eaten;
}

int Pacman::get_score()
{
    return ghosts_eaten * 200 + times_died * (-500) + dots_eaten * 5;
}

void Pacman::die()
{
    ++times_died;
}

void Pacman::roadblock_callback()
{
    dir = NONE;
    return;
}


void Pacman::move()
{
    Actor::move();

    Tile curTile = this->get_tile();
    if(map[curTile.x][curTile.y] == DOT || map[curTile.x][curTile.y] == ENERGIZER)
    {
        ++dots_eaten;
        dotEaten(curTile.x, curTile.y);
    }
}

int Pacman::get_dots_eaten()
{
    return dots_eaten;
}
